from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.routers import auth_router, dict_router, spot_router, file_router, spot_extra_router
from app.db.database import Base, engine

# 建表（开发期）- 使用 checkfirst=True 避免重复创建
try:
    Base.metadata.create_all(bind=engine, checkfirst=True)
except Exception as e:
    print(f"数据库表创建警告: {e}")
app = FastAPI(title="智行合旅 API", version="0.1.0")
app.add_middleware(
    CORSMiddleware, allow_origins=["*"],
    allow_credentials=True, allow_methods=["*"], allow_headers=["*"]
)
app.include_router(auth_router.router, prefix="/auth")
app.include_router(dict_router.router, prefix="/dict")
app.include_router(spot_router.router) # 景点
app.include_router(file_router.router) # 文件
app.include_router(spot_extra_router.router) # 景点复杂操作
